from typing import AsyncIterator, Any

import scrapy
from scrapy.mail import MailSender


class EmailsSpider(scrapy.Spider):
    name = "emails"

    async def start(self):
        url = "https://httpbin.org/get?a=10"
        yield scrapy.Request(url)

    def parse(self, response):
        mailer = MailSender.from_settings(self.settings)
        mailer.send(
            to=["731422750@qq.com"],
            subject="Scrapy 爬取结果",
            body=f"今日共抓到 200 条数据",
        )
